package cn.qidd.keep.manage.controller.system;

import cn.qidd.keep.domain.core.Result;
import cn.qidd.keep.domain.document.Resource;
import cn.qidd.keep.domain.web.BaseController;
import cn.qidd.keep.manage.model.system.ResourceParams;
import cn.qidd.keep.manage.repository.ResourceRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by sunyanping on 2018/9/17
 */
@RestController
@RequestMapping("/api/resource")
@Api(value = "ResourceController",description = "资源管理")
public class ResourceController extends BaseController {

    @Autowired
    private ResourceRepository resourceRepository;

    @PostMapping
    @ApiOperation(value = "增加资源", notes = "增加资源")
    public Result createResource(@RequestBody ResourceParams params) {
        Resource mongoResource = new Resource();
        BeanUtils.copyProperties(params, mongoResource);
        resourceRepository.save(mongoResource);
        return new Result(Result.Status.SUCCESS, "");
    }
}
